#region Summary

// 
// Owner : JackieHan 
// 
// Solution : LearnSolution 
// 
// Project : JackieHan.NHibernate3.Test
// 
// File : TestSetMapping.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 测试Set集合Mapping
// 
// History : 
//			2010-09-15 01:29:38	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using Iesi.Collections.Generic;
using JackieHan.NHibernate3.Domain;
using JackieHan.NHibernate3.Repository;
using NUnit.Framework;

#endregion

namespace JackieHan.NHibernate3.Test
{
    /// <summary> 
    /// 测试Set集合Mapping
    /// </summary>
    [TestFixture]
    public class TestSetMapping
    {
        //private SetOfElements item;

        [SetUp]
        public void SetUp()
        {
            
        }

        [Test]
        public void TestBaseTypeSet()
        {
            SetOfElements item = new SetOfElements();
            item.CreateDate = DateTime.Now;
            item.Creator = "admin";
            item.Elements = new HashedSet<String> { "aa", "bb", "cc" };
            item.LastUpdateDate = DateTime.Now;
            item.Name = "jackieHan";
            item.Updator = "admin";
            item.Version += 1;
            SetOfElementsRepository dbManager = new SetOfElementsRepository();
            dbManager.Save(item);
        }

        [Test]
        public void TestComponentSet()
        {
            SetOfComponents componentItem = new SetOfComponents
                                      {
                                          CreateDate = DateTime.Now,
                                          Creator = "admin",
                                          Updator = "admin",
                                          LastUpdateDate = DateTime.Now,
                                          Name = "jackieHan",
                                          Version = 1,
                                          Components = new HashedSet<ComponentSet>()
                                                          {
                                                              new ComponentSet {StringProperty="string",IntProperty = 1},
                                                              new ComponentSet{StringProperty = "string",IntProperty = 2},    
                                                              new ComponentSet{StringProperty = "string",IntProperty = 3},
                                                              new ComponentSet{StringProperty = "string",IntProperty = 4},
                                                          }
                                      };
            SetOfComponentsRepository dbManager = new SetOfComponentsRepository();
            dbManager.Save(componentItem);
        }

        [Test]
        public void TestOneToManySet()
        {
            SetOfOneToMany item = new SetOfOneToMany
                                      {
                                          CreateDate = DateTime.Now,
                                          Creator = "admin",
                                          Updator = "admin",
                                          LastUpdateDate = DateTime.Now,
                                          Version = 1,
                                          OneToManys = new HashedSet<OneToManySet>
                                                           {
                                                               new OneToManySet(),
                                                               new OneToManySet(),
                                                               new OneToManySet(),
                                                               new OneToManySet(),
                                                               new OneToManySet()
                                                           }
                                      };
            SetOfOneToManyRepository db = new SetOfOneToManyRepository();
            db.Save(item);
        }

        [Test]
        public void TestManyToManySet()
        {
            SetOfManyToMany item = new SetOfManyToMany()
                                       {
                                           CreateDate = DateTime.Now,
                                           Creator = "admin",
                                           LastUpdateDate = DateTime.Now,
                                           Updator = "admin",
                                           Version = 1,
                                           ManyToManys = new HashedSet<ManyToManySet>
                                                             {
                                                                 new ManyToManySet(),
                                                                 new ManyToManySet(),
                                                                 new ManyToManySet(),
                                                                 new ManyToManySet()
                                                             }
                                       };
            SetOfManyToManyRepository db = new SetOfManyToManyRepository();
            db.Save(item);
        }
    }
}